function Magnifier() {
    this.focus = $(".focus")
    this.small_img_wrapper = $(".small-img"); 
    this.big_img_focus = $(".big-img");              
    this.big_img = $(".big-img img");
    this.container = $(".container");               
    this.small_img = $(".small-img img");


    
    this.container_offset = this.container.offset();
}

Magnifier.prototype.bindEvent = function () {
    var instance = this;
    this.small_img_wrapper.mouseover(
          function () {
                instance.toggle("block");
          }
    )
    this.small_img_wrapper.mouseout(
          function () {
                instance.toggle("none");
          }
    )
    this.small_img_wrapper.mousemove(function (evt) {
          var e = evt || event;
          instance.move(e.clientX - instance.container_offset["left"], e.clientY -
                instance.container_offset["top"]);
    })

}
// 切换图片显示隐藏; 
Magnifier.prototype.toggle = function (type) {
    this.focus.css({
          display: type
    })
    this.big_img_focus.css({
          display: type
    })

}

Magnifier.prototype.move = function (x, y) {
    var _left = x - parseInt(this.focus.width()) / 2
    var _top = y - parseInt(this.focus.height()) / 2
    var a = this.small_img_wrapper.width() - this.focus.width()
    var b = this.small_img_wrapper.height() - this.focus.height()
    _left = _left < 0 ? 0 : _left;
    _left = _left > a ? a : _left;
    _top = _top < 0 ? 0 : _top;
    _top = _top > b ? b : _top;
    this.focus.css({
          left: _left,
          top: _top
    })
    var _left_per = _left / a;
    var _top_per = _top / b;
    this.big_img.css({
          left: -(this.big_img.width() - this.big_img_focus.width()) * _left_per,
          top: -(this.big_img.height() - this.big_img_focus.height()) * _top_per
    })

}
Magnifier.prototype.changeItem = function (index) {
    this.pagination_bullets.toggleClass("active");
    $(this.small_img).attr("src", this.img_list[index].small)
    $(this.big_img).attr("src", this.img_list[index].big)

}
var m = new Magnifier();


m.bindEvent();